package cn.net.asiacom.config;

public enum RegexEnum {
    /**
     * 发票代码正则提取（旧版发票有发票代码，新版发票没有）
     */
    REGEX_INVOICE_CODE("发票代码:(?<code>\\d{12})"),
    /**
     * 发票代码跨行提取正则
     */
    REGEX_INVOICE_CODE_1("发票代码:(?<code>\\d{10})[\\s\\S]*?(\\d+)"),

    /**
     * 发票类型提取正则，匹配"xxx通发票"格式的发票类型
     */
    REGEX_INVOICE_TYPE_P("(?<p>\\S*)通发票|普发票|普通制"),
    /**
     * 发票类型提取正则，匹配"xxx用发票"格式的发票类型 专一
     */
    REGEX_INVOICE_TYPE_Z("(?<p>\\S*)用发票|专发票|专用制"),
    /**
     * 发票类型提取 - 辅助正则
     */
    REGEX_INVOICE_TYPE_AUX("(?:国|统|一|发|票|监|制)"),


    /**
     * 发票号码提取
     */
    REGEX_INVOICE_NUMBER("发票号码:(?<number>(\\d{20}|\\d{8}))"),
    /**
     * 发票号码备用提取正则
     */
    REGEX_INVOICE_NUMBER_1("(国制|制普通发票)(?<number>\\d{8})"),
    /**
     * 发票号码跨行提取正则
     */
    REGEX_INVOICE_NUMBER_2("发票号码:(?<number>\\d{7})[\\s\\S]*?(\\d+)"),

    /**
     * 开票日期提取正则
     */
    REGEX_INVOICE_DATE("(?<date>\\d{4}年\\d{2}月\\d{2}日)"),
    /**
     * 开票日期提取正则备用
     */
    REGEX_INVOICE_DATE_1("开票日期:(?<date>\\d{4}\\d{2}月\\d{2}日)"),

    /**
     * 收款人、复核、开票人、销售方提取正则，匹配格式为“收款人:xxx复核:xxx开票人:xxx销售方”的字符串
     */
    REGEX_INVOICE_DRAWER("收款人:(?<payee>\\S*)复核:(?<reviewer>\\S*)开票人:(?<drawer>\\S*)销售方"),
    /**
     * 开票人提取正则，匹配格式为“开票人:xxx”的字符串
     */
    REGEX_INVOICE_DRAWER_1("开票人:(?<drawer>\\S*)"),


    /**
     * 购买方信息提取正则
     */
    REGEX_INVOICE_BUYER("名称:(?<name>\\S*)|纳税人识别号:(?<code>\\S*)|地址、电话:(?<address>\\S*)|开户行及账号:(?<account>\\S*)|电子支付标识:(?<account2>\\S*)"),
    /**
     * 针对深圳发票的销售方名称提取正则
     */
    REGEX_INVOICE_BUYER_1("名称:(?<name>\\S*)"),
    /**
     * 购买方信息、统一社会信用代码/纳税人识别号的提取正则 （新版发票）
     * (售名称|销名称):(?<name>\S*)
     */
    REGEX_INVOICE_BUYER_2("(?<date>\\d{4}年\\d{2}月\\d{2}日)|(售名称|销名称):(?<name>\\S*)"),
    REGEX_INVOICE_BUYER_3("(购名称|买名称):(?<name>\\S*)(售名称|销名称)|统一社会信用代码/纳税人识别号:(?<code>\\w{18})"),


    /**
     * 金额、税额提取正则，匹配形如 "合计¥?金额¥?税额" 的文本
     */
    REGEX_INVOICE_AMOUNT("合计¥?(?<amount>[^ \\f\\n\\r\\t\\v*]*)(?:¥?(?<taxAmount>\\S*)|\\*+)\\s"),
    REGEX_INVOICE_AMOUNT_B("合计¥?([0-9]+\\.[0-9]+)¥?([0-9]+\\.[0-9]+)"),

    /**
     * 金额、税额备用提取正则
     */
    REGEX_INVOICE_AMOUNT_1("合\\u0020*计\\u0020*¥?(?<amount>[^ ]*)\\u0020+¥?(?:(?<taxAmount>\\S*)|\\*+)\\s"),
    /**
     * 金额、税额备用提取正则
     */
    REGEX_INVOICE_AMOUNT_2("合[^ ]*计\\u0020*¥?(?<amount>[^ ]*)\\u0020+¥?(?:(?<taxAmount>\\S*)|\\*+)\\s"),
    /**
     * 金额提取正则，用于匹配结果有误的修正
     */
    REGEX_INVOICE_AMOUNT_3("合计¥(?<amount>\\d+\\.\\d+)"),

    /**
     * 价税合计提取正则，匹配“价税合计（大写）XXX（小写）¥YYY”格式的文本
     */
    REGEX_INVOICE_AMOUNT_C("价税合计\\u0028大写\\u0029(?<amountString>\\S*)\\u0028小写\\u0029¥?(?<amount>\\S*)\\s"),


    TICKET_INVOICE_NUMBER("发票号码:(?<number>\\d*)\\S*"),
    TICKET_INVOICE_DATE("开票日期:(?<date>\\d{4}年\\d{2}月\\d{2}日)"),
    TICKET_INVOICE_AMOUNT("票价:¥?([0-9]+\\.[0-9]+)"),
    TICKET_INVOICE_STATION("(\\p{L}+站)(\\p{L}\\d+)(\\p{L}+站)"),
    TICKET_INVOICE_TRAIN("(\\d{4}年\\d{2}月\\d{2}日)\\s*(\\d{2}:\\d{2})开(\\d+车)(\\d+[A-Za-z])号(\\p{L}+座)"),
    TICKET_INVOICE_PASSENGER("([0-9]{10}[*]{4}\\S{4})(\\S*)"),
    TICKET_INVOICE_E_TICKET_NUMBER("电子客票号:(\\d+)"),
    TICKET_INVOICE_BUYER("购买方名称:(.*?)统一社会信用代码:(\\S*)"),

    ;
    private final String regex;
    RegexEnum(String regex) {
        this.regex = regex;
    }
    public String getRegex() {
        return regex;
    }
}
